/// @tags: NodeDiv
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

namespace BlueQuantum {

int const N = 2e4 + 5;

struct Edge {
  int v, nxt, w;
} e[N << 1];

int n, e_cnt, rt, cursum, ans;
int heads[N], siz[N], maxn[N], d[3], newd[3];
bool vis[N];

inline void add(int u, int v, int w) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt, e[e_cnt].w = w;
}

int getGCD(int a, int b) { return b ? getGCD(b, a % b) : a; }

void getRoot(int u, int fa) {
  siz[u] = 1, maxn[u] = 0;
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa && !vis[v]) {
      getRoot(v, u);
      siz[u] += siz[v];
      maxn[u] = max(maxn[u], siz[v]);
    }
  }
  maxn[u] = max(maxn[u], cursum - siz[u]);
  if (maxn[u] < maxn[rt]) rt = u;
}

void dfs(int u, int fa, int dep) {
  newd[dep % 3]++;
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa && !vis[v]) { dfs(v, u, dep + e[i].w); }
  }
}

void solve(int u) {
  vis[u] = true;
  memset(d, 0, sizeof(d));
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if (!vis[v = e[i].v]) {
      memset(newd, 0, sizeof(newd));
      dfs(v, u, e[i].w);
      ans += 2 * (d[2] * newd[1] + newd[2] * d[1] + newd[0] * d[0] + newd[0]);
      for (int j = 0; j < 3; ++j) d[j] += newd[j];
    }
  }
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if (!vis[v = e[i].v]) {
      cursum = siz[v];
      rt = 0;
      getRoot(v, u);
      solve(rt);
    }
  }
}

inline int main() {
  cin >> n;
  for (int i = 1, u, v, w; i < n; ++i) {
    cin >> u >> v >> w;
    add(u, v, w), add(v, u, w);
  }
  maxn[0] = n + 1;
  cursum = n, getRoot(1, 1);
  solve(rt);
  int gcd = getGCD(ans + n, n * n);
  cout << (ans + n) / gcd << '/' << n * n / gcd;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P2634 [国家集训队] 聪聪可可.in", "r", stdin);
  freopen("P2634 [国家集训队] 聪聪可可.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
